<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue3 响应式代码</title>
</head>

<body>
    <div id="app"></div>
    <button id="btn">点我加年龄</button>
    <script src="./reactivity.js"></script>
    <script>
        const obj = reactive({
            name: 'wcly',
            age: 18,
        })
        let doubleAge = computed(() => obj.age * 2)
        effect(() => {
            app.innerHTML = `<h1>姓名：${obj.name}, 年龄：${obj.age}, 两倍的年龄：${doubleAge.value}</h1>`
        })
        btn.addEventListener('click', () => {
            obj.age += 1;
        }, false)
    </script>
</body>

</html>